package com.ruoyi.jiajia.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaChongzhiRecord;
import com.ruoyi.system.service.IJiajiaChongzhiRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 充值记录Controller
 * 
 * @author knd
 * @date 2021-10-13
 */
@Controller
@RequestMapping("/jiajia/chongZhiRecord")
public class JiajiaChongzhiRecordController extends BaseController
{
    private String prefix = "jiajia/chongZhiRecord";

    @Autowired
    private IJiajiaChongzhiRecordService jiajiaChongzhiRecordService;

    @RequiresPermissions("jiajia:chongZhiRecord:view")
    @GetMapping()
    public String chongZhiRecord()
    {
        return prefix + "/chongZhiRecord";
    }

    /**
     * 查询充值记录列表
     */
    @RequiresPermissions("jiajia:chongZhiRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaChongzhiRecord jiajiaChongzhiRecord)
    {
        startPage();
        List<JiajiaChongzhiRecord> list = jiajiaChongzhiRecordService.selectJiajiaChongzhiRecordList(jiajiaChongzhiRecord);
        return getDataTable(list);
    }

    /**
     * 导出充值记录列表
     */
    @RequiresPermissions("jiajia:chongZhiRecord:export")
    @Log(title = "充值记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaChongzhiRecord jiajiaChongzhiRecord)
    {
        List<JiajiaChongzhiRecord> list = jiajiaChongzhiRecordService.selectJiajiaChongzhiRecordList(jiajiaChongzhiRecord);
        ExcelUtil<JiajiaChongzhiRecord> util = new ExcelUtil<JiajiaChongzhiRecord>(JiajiaChongzhiRecord.class);
        return util.exportExcel(list, "充值记录数据");
    }

    /**
     * 新增充值记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存充值记录
     */
    @RequiresPermissions("jiajia:chongZhiRecord:add")
    @Log(title = "充值记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaChongzhiRecord jiajiaChongzhiRecord)
    {
        return toAjax(jiajiaChongzhiRecordService.insertJiajiaChongzhiRecord(jiajiaChongzhiRecord));
    }

    /**
     * 修改充值记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaChongzhiRecord jiajiaChongzhiRecord = jiajiaChongzhiRecordService.selectJiajiaChongzhiRecordById(id);
        mmap.put("jiajiaChongzhiRecord", jiajiaChongzhiRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存充值记录
     */
    @RequiresPermissions("jiajia:chongZhiRecord:edit")
    @Log(title = "充值记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaChongzhiRecord jiajiaChongzhiRecord)
    {
        return toAjax(jiajiaChongzhiRecordService.updateJiajiaChongzhiRecord(jiajiaChongzhiRecord));
    }

    /**
     * 删除充值记录
     */
    @RequiresPermissions("jiajia:chongZhiRecord:remove")
    @Log(title = "充值记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaChongzhiRecordService.deleteJiajiaChongzhiRecordByIds(ids));
    }
}
